/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Amazon.ECS;
using Amazon.ECS.Model;

namespace Amazon.ECS.Samples
{

    /// <summary>
    /// Seller Lookup  Samples
    /// </summary>
    public class SellerLookupSample
    {
    
                                                             
        /// <summary>
        /// 
        /// <p/>
        /// The SellerLookup operation returns detailed information about sellers and,
        /// in the US locale, merchants. To lookup a seller, you must use their seller ID.
        /// The information returned includes the seller's name, location, average rating by
        /// customers, and the first five customer feedback entries. SellerLookup will not,
        /// however, return the seller's Email or business addresses.
        /// <p/>
        /// <b>Available Response Groups</b>:
        /// <ul>
        /// <li>Request</li>
        /// <li>Seller</li>
        /// </ul>
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonECS service</param>
        /// <param name="request">SellerLookup request</param>
        public static void InvokeSellerLookup(AmazonECS service, params SellerLookupRequest [] request) 
        {
            try 
            {
                SellerLookupResponse response = service.SellerLookup(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        SellerLookupResponse");
                if (response.IsSetOperationRequest()) 
                {
                    Console.WriteLine("            OperationRequest");
                    OperationRequest  operationRequest = response.OperationRequest;
                    if (operationRequest.IsSetHTTPHeaders()) 
                    {
                        Console.WriteLine("                HTTPHeaders");
                        HTTPHeaders  HTTPHeaders = operationRequest.HTTPHeaders;
                    } 
                    if (operationRequest.IsSetRequestId()) 
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", operationRequest.RequestId);
                    }
                    if (operationRequest.IsSetArguments()) 
                    {
                        Console.WriteLine("                Arguments");
                        Arguments  arguments = operationRequest.Arguments;
                    } 
                    if (operationRequest.IsSetRequestProcessingTime()) 
                    {
                        Console.WriteLine("                RequestProcessingTime");
                        Console.WriteLine("                    {0}", operationRequest.RequestProcessingTime);
                    }
                } 
                List<Sellers> sellersList = response.Sellers;
                foreach (Sellers sellers in sellersList) 
                {
                    Console.WriteLine("            Sellers");
                    if (sellers.IsSetTotalResults()) 
                    {
                        Console.WriteLine("                TotalResults");
                        Console.WriteLine("                    {0}", sellers.TotalResults);
                    }
                    if (sellers.IsSetTotalPages()) 
                    {
                        Console.WriteLine("                TotalPages");
                        Console.WriteLine("                    {0}", sellers.TotalPages);
                    }
                    List<Seller> sellerList = sellers.Seller;
                    foreach (Seller seller in sellerList) 
                    {
                        Console.WriteLine("                Seller");
                        if (seller.IsSetSellerId()) 
                        {
                            Console.WriteLine("                    SellerId");
                            Console.WriteLine("                        {0}", seller.SellerId);
                        }
                        if (seller.IsSetSellerName()) 
                        {
                            Console.WriteLine("                    SellerName");
                            Console.WriteLine("                        {0}", seller.SellerName);
                        }
                        if (seller.IsSetSellerLegalName()) 
                        {
                            Console.WriteLine("                    SellerLegalName");
                            Console.WriteLine("                        {0}", seller.SellerLegalName);
                        }
                        if (seller.IsSetNickname()) 
                        {
                            Console.WriteLine("                    Nickname");
                            Console.WriteLine("                        {0}", seller.Nickname);
                        }
                        if (seller.IsSetGlancePage()) 
                        {
                            Console.WriteLine("                    GlancePage");
                            Console.WriteLine("                        {0}", seller.GlancePage);
                        }
                        if (seller.IsSetAbout()) 
                        {
                            Console.WriteLine("                    About");
                            Console.WriteLine("                        {0}", seller.About);
                        }
                        if (seller.IsSetMoreAbout()) 
                        {
                            Console.WriteLine("                    MoreAbout");
                            Console.WriteLine("                        {0}", seller.MoreAbout);
                        }
                        if (seller.IsSetLocation()) 
                        {
                            Console.WriteLine("                    Location");
                            SellerLocation  location = seller.Location;
                            if (location.IsSetUserDefinedLocation()) 
                            {
                                Console.WriteLine("                        UserDefinedLocation");
                                Console.WriteLine("                            {0}", location.UserDefinedLocation);
                            }
                            if (location.IsSetCity()) 
                            {
                                Console.WriteLine("                        City");
                                Console.WriteLine("                            {0}", location.City);
                            }
                            if (location.IsSetState()) 
                            {
                                Console.WriteLine("                        State");
                                Console.WriteLine("                            {0}", location.State);
                            }
                            if (location.IsSetCountry()) 
                            {
                                Console.WriteLine("                        Country");
                                Console.WriteLine("                            {0}", location.Country);
                            }
                        } 
                        if (seller.IsSetAverageFeedbackRating()) 
                        {
                            Console.WriteLine("                    AverageFeedbackRating");
                            Console.WriteLine("                        {0}", seller.AverageFeedbackRating);
                        }
                        if (seller.IsSetTotalFeedback()) 
                        {
                            Console.WriteLine("                    TotalFeedback");
                            Console.WriteLine("                        {0}", seller.TotalFeedback);
                        }
                        if (seller.IsSetTotalFeedbackPages()) 
                        {
                            Console.WriteLine("                    TotalFeedbackPages");
                            Console.WriteLine("                        {0}", seller.TotalFeedbackPages);
                        }
                        if (seller.IsSetSellerFeedbackSummary()) 
                        {
                            Console.WriteLine("                    SellerFeedbackSummary");
                            SellerFeedbackSummary  sellerFeedbackSummary = seller.SellerFeedbackSummary;
                            List<FeedbackDateRange> feedbackDateRangeList = sellerFeedbackSummary.FeedbackDateRange;
                            foreach (FeedbackDateRange feedbackDateRange in feedbackDateRangeList) 
                            {
                                Console.WriteLine("                        FeedbackDateRange");
                                List<SellerFeedbackRating> sellerFeedbackRatingList = feedbackDateRange.SellerFeedbackRating;
                                foreach (SellerFeedbackRating sellerFeedbackRating in sellerFeedbackRatingList) 
                                {
                                    Console.WriteLine("                            SellerFeedbackRating");
                                    if (sellerFeedbackRating.IsSetCount()) 
                                    {
                                        Console.WriteLine("                                Count");
                                        Console.WriteLine("                                    {0}", sellerFeedbackRating.Count);
                                    }
                                    if (sellerFeedbackRating.IsSetPercentage()) 
                                    {
                                        Console.WriteLine("                                Percentage");
                                        Console.WriteLine("                                    {0}", sellerFeedbackRating.Percentage);
                                    }
                                }
                            }
                        } 
                        if (seller.IsSetSellerFeedback()) 
                        {
                            Console.WriteLine("                    SellerFeedback");
                            SellerFeedback  sellerFeedback = seller.SellerFeedback;
                            List<Feedback> feedbackList = sellerFeedback.Feedback;
                            foreach (Feedback feedback in feedbackList) 
                            {
                                Console.WriteLine("                        Feedback");
                                if (feedback.IsSetRating()) 
                                {
                                    Console.WriteLine("                            Rating");
                                    Console.WriteLine("                                {0}", feedback.Rating);
                                }
                                if (feedback.IsSetComment()) 
                                {
                                    Console.WriteLine("                            Comment");
                                    Console.WriteLine("                                {0}", feedback.Comment);
                                }
                                if (feedback.IsSetDate()) 
                                {
                                    Console.WriteLine("                            Date");
                                    Console.WriteLine("                                {0}", feedback.Date);
                                }
                                if (feedback.IsSetRatedBy()) 
                                {
                                    Console.WriteLine("                            RatedBy");
                                    Console.WriteLine("                                {0}", feedback.RatedBy);
                                }
                            }
                        } 
                    }
                }

            } 
            catch (AmazonECSException ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
                                            }
}
